package com.hr.entity;

/**
 * 结果集类 
 * 用于视图层的展示，它没有映射数据库的表
 * @author 86173
 *
 */
public class R {
	//状态码 0 ：表示操作失败  1：表示操作成功
	private Integer statusCode = 1;
	
	//当前页码
	private Integer page;
	//每页大小
	private Integer pageSize;
	//总记录数
	private Integer total;
	//数据
	private Object data;
	
	/**
	 * 创建一个成功的结果集对象
	 * @param data
	 * @return
	 */
	public static R ok(Object data) {
		R r = new R();
		r.setData(data);
		r.setStatusCode(1);
		return r;
	}
	/**
	 * 创建一个失败的结果集对象
	 * @param data
	 * @return
	 */
	public static R fail(Object data) {
		R r = new R();
		r.setData(data);
		r.setStatusCode(0);
		return r;
	}
	
	
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public Integer getStatusCode() {
		return statusCode;
	}
	public void setStatusCode(Integer statusCode) {
		this.statusCode = statusCode;
	}
	@Override
	public String toString() {
		return "R {page=" + page + ", pageSize=" + pageSize + ", total=" + total + ", data=" + data + "}";
	}
	
	
	
}
